package com.biz.primus.ms.oms.dao.repository;

import com.biz.primus.ms.oms.dao.po.OmsOrderItem;
import com.biz.primus.ms.oms.dao.po.returns.OmsReturn;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author LGJ
 * @date  2017/11/11
 */
public interface OmsOrderReturnRepository extends JpaRepository<OmsReturn,Long>,JpaSpecificationExecutor<OmsReturn> {

    /**
     * 根据退单编码查询退单
     * @param returnCode
     * @return
     */
    OmsReturn findByReturnCode(String returnCode);

    /**
     * 根据订单ID查询退单
     * @param orderId
     * @return
     */
    OmsReturn findByOrderId(Long orderId);

    /**
     * 根据退单编码查询是否存在
     * @param returnCode
     * @return
     */
    @Query("select count(o.id) from OmsReturn o where o.returnCode = ?1")
    int isExistOrder(String returnCode);



}
